package com.gyy.androidlibraryapp.fragments;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.gyy.androidlibraryapp.R;
import com.ymdd.library.toasty.Toasty;

import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 自定义toast
 */
public class ToastyFragment extends Fragment {
    Unbinder unbinder;


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        View view = inflater.inflate(R.layout.fragment_toasty, null);

        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.bt_success, R.id.bt_warning, R.id.bt_error, R.id.bt_normal})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.bt_success:
                Toasty.success(this.getContext(), "bt_success").show();
                break;
            case R.id.bt_warning:
                Toasty.warning(this.getContext(), "bt_warning").show();
                break;
            case R.id.bt_error:
                Toasty.error(this.getContext(), "bt_error").show();
                break;
            case R.id.bt_normal:
                Toasty.normal(this.getContext(), "bt_normal").show();
                break;
        }
    }
}
